package com.java.demo.component;

import org.springframework.beans.factory.BeanNameAware;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class BeanComponent implements BeanNameAware {

    @Override
    public void setBeanName(String s) {
        System.out.println("执行了通知 BeanName -> " + s);
    }
    /*xml 初始化方法*/
    public void myInit() {
        System.out.println("XML 方式初始化 ");
    }
    @PostConstruct
    public void doPostConstruct() {
        System.out.println("注解的初始化方法");
    }

    public void sayHi() {
        System.out.println("执行 sayHi（）");
    }

    @PreDestroy
    public void doPreDestroy() {
        System.out.println("do PreDestroy");
    }
}
